package com.info.zhiduoduo.admin.controller;

import com.info.zhiduoduo.admin.model.formbean.recharge.QueryRechargeRecordFormBean;
import com.info.zhiduoduo.admin.model.formbean.recharge.SaveRechargeRecordFormBean;
import com.info.zhiduoduo.admin.model.formbean.value.QueryValueFormBean;
import com.info.zhiduoduo.admin.service.RechargeService;
import com.info.zhiduoduo.admin.service.ValueService;
import com.info.zhiduoduo.common.annotation.LogEntity;
import com.info.zhiduoduo.common.annotation.LogParameter;
import com.info.zhiduoduo.common.annotation.ZddLog;
import com.info.zhiduoduo.common.constants.SmartResult;
import com.info.zhiduoduo.common.constants.system.ZddLogType;
import com.info.zhiduoduo.common.formbean.BaseSimpleFormBean;
import com.info.zhiduoduo.repository.dto.recharge.RechargeRecordDto;
import com.info.zhiduoduo.repository.entity.recharge.RechargeRecord;
import com.info.zhiduoduo.repository.entity.recharge.RechargeType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author tianyonghong
 * @create 2021/12/9
 */
@Api(tags = "收费记录")
@RestController
@RequestMapping("/recharge")
public class RechargeController {

    @Resource
    private RechargeService rechargeService;

    @ApiOperation("查询收费记录")
    @PostMapping("/queryRechargeRecordList")
    public SmartResult<RechargeRecordDto> queryRechargeRecordList(@RequestBody BaseSimpleFormBean<QueryRechargeRecordFormBean> baseSimpleFormBean){
        return rechargeService.queryRechargeRecordList(baseSimpleFormBean);
    }

    @ZddLog(name = "新增收费记录")
    @ApiOperation("新增收费记录")
    @PostMapping("/saveRechargeRecord")
    public SmartResult saveRechargeRecord(@RequestBody BaseSimpleFormBean<SaveRechargeRecordFormBean> baseSimpleFormBean){
        return rechargeService.saveOrUpdateRechargeRecord(baseSimpleFormBean);
    }

    @ZddLog(type = ZddLogType.DELETE,name = "删除收费记录",entities = @LogEntity(entity = RechargeRecord.class,parameters =
    @LogParameter(fields = "rechargeId",parameters = "baseSimpleFormBean.reqdata")))
    @ApiOperation("删除收费记录")
    @PostMapping("/delRechargeRecord")
    public SmartResult delRechargeRecord(@RequestBody BaseSimpleFormBean<Integer> baseSimpleFormBean){
        return rechargeService.delRechargeRecord(baseSimpleFormBean.getReqdata());
    }

    @ApiOperation("查询收费类型")
    @PostMapping("/queryAllRechargeType")
    public SmartResult<RechargeType> queryAllRechargeType(@RequestBody BaseSimpleFormBean baseSimpleFormBean){
        return rechargeService.queryAllRechargeType(baseSimpleFormBean);
    }

}
